

/*---------------------------------------------------------
   Initializes the effect. The data is a table of data 
   which was passed from the server.
---------------------------------------------------------*/
function EFFECT:Init( data )

	self.LifeTime = CurTime() + math.random( 10, 20 )

	local count = table.Count( BodyGibs )
	local model = BodyGibs[ math.random( 1,count ) ]
	if (model == nil) then model = "models/gibs/HGIBS_rib.mdl" end

	self:SetModel( model )
	self:PhysicsInit( SOLID_VPHYSICS )
	self:SetMoveType( MOVETYPE_VPHYSICS )
	self:SetSolid( SOLID_VPHYSICS ) 
	self:SetPos(data:GetOrigin() + (VectorRand() * math.random( 1, 16 )))
	self:SetMaterial( "models/flesh" )
	local phys = self:GetPhysicsObject()
	
	if (!phys:IsValid()) then
		self:Remove()
		print("Error! "..model.." is not a valid prop model!\n")
	end
	
	self:SetCollisionGroup( COLLISION_GROUP_WEAPON )
	
	if ( phys && phys:IsValid() ) then
	
		phys:Wake()
		phys:SetAngle( Angle( math.Rand(0,359), math.Rand(0,359), math.Rand(0,359) ) )
		phys:SetVelocity( Vector(math.random(-100,100),math.random(-100,100),math.random(100,200)) )
		phys:AddAngleVelocity(Angle(math.random(-250,250),math.random(-250,250),math.random(-250,250)))
	
	end
	
	local emitter = ParticleEmitter( data:GetOrigin() )
	
	for i=1,math.random(5,10) do
		local particle = emitter:Add( "effects/blood_core", data:GetOrigin() )
		particle:SetVelocity( Vector(math.random(-50,50),math.random(-50,50),math.random(10,100)) )
		particle:SetDieTime( 0.6 )
		particle:SetStartAlpha( 250 )
		particle:SetEndAlpha( 0 )
		particle:SetStartSize( math.Rand(1,10) )
		particle:SetEndSize( math.Rand(40,60) )
		particle:SetRoll( math.Rand( 0, 360 ) )
		particle:SetColor( 170, 0, 0 )
	end
	
end


/*---------------------------------------------------------
   THINK
   Returning false makes the entity die
---------------------------------------------------------*/
function EFFECT:Think( )
return CurTime() <= self.LifeTime end

/*---------------------------------------------------------
   Draw the effect
---------------------------------------------------------*/
function EFFECT:Render()

	self:DrawModel()

end



